package com.twu.biblioteca.model.item;

/**
 * Created with IntelliJ IDEA.
 * User: cschlumb
 * Date: 08/08/2013
 * Time: 12:18
 * To change this template use File | Settings | File Templates.
 */
public class ItemID {

    private static int lastID = 0;
    private int id;

    public ItemID(int id){
        this.id = id;
    }

    private ItemID(){
        id = lastID++;
    }

    public static ItemID nextID(){
        return new ItemID();
    }

    public int getId() {
        return id;
    }

    @Override
    public String toString() {
        return String.valueOf(id);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ItemID itemID = (ItemID) o;

        if (id != itemID.id) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return id;
    }
}
